package com.dfec.utils ;

import java.util.Random ;
public class Token {
	public static final int TOKENLENGTH = 64 ;
	public static final int AVATARLENGTH = 16 ;
	public static final int DEFAULT_RANDOM_PASSWORD_LENGTH = 6 ;
	//@formatter:off
	private static String [ ] upcaseLetter = { 	"A" , "B" , "C" , "D" , "E" , 
												"F" , "G" , "H" , "I" , "J" , 
												"K" , "L" , "M" , "N" , "O" , 
												"P" , "Q" , "R" , "S" , "T" , 
												"U" , "V" , "W" , "X" , "Y" , 
												"Z" } ;
	private static String [ ] lowercaseLetter = { 	"a" , "b" , "c" , "d" , "e" , 
													"f" , "g" , "h" , "i" , "j" , 
													"k" , "l" , "m" , "n" , "o" , 
													"p" , "q" , "r" , "s" , "t" , 
													"u" , "v" , "w" , "x" , "y" , 
													"z" } ;
	private static String [] num={"0","1","2","3","4","5","6","7","8","9"};
	//@formatter:on
	public static String makeToken ( int Length ) {
		StringBuilder token = new StringBuilder ( ) ;
		for ( int i = 0 ; i < Length ; i ++ ) {
			int tmpInt = Math.abs ( new Random ( ).nextInt ( ) % 3 ) ;
			String tmpStr = "" ;
			switch ( tmpInt ) {
				case 0 :
					tmpStr = upcaseLetter [ new Random ( ).nextInt ( upcaseLetter.length ) ] ;
					break ;
				case 1 :
					tmpStr = lowercaseLetter [ new Random ( ).nextInt ( lowercaseLetter.length ) ] ;
					break ;
				case 2 :
					tmpStr = num [ new Random ( ).nextInt ( num.length ) ] ;
					break ;
				default :
					break ;
			}
			token.append ( tmpStr ) ;
		}
		return token.toString ( ) ;
	}
}
